# # 闭包
# def outer(x):
#     def inner(y):
#         print(f"x={x}, y={y}")
#     return inner
# f = outer(10)
# f(20) # 输出：x=10, y=20
#
#
# # 装饰器
# def outer(func):
#     def inner():
#         print("before:", end=" ")
#         func()
#         print(":after")
#     return inner
# fn=outer(lambda:print("hello world", end=" "))
# fn() # 输出：before hello world after
#
#
# # 语法糖
# def outer(func):
#     def inner():
#         print("before:", end=" ")
#         func()
#         print(":after")
#     return inner
# @outer
# def fn():
#     print("hello world", end=" ")
# fn() # 输出：before hello world after


# import time, threading
# def woker():
#     while True:
#         print("worker is running")
#         time.sleep(2)
# def runner():
#     while True:
#         print("runner is running")
#         time.sleep(1)
# if __name__=="__main__":
#     t1=threading.Thread(target=woker)
#     t2=threading.Thread(target=runner)
#     t1.start()
#     t2.start()



import re
# 匹配字符串开头的数字
str="python 12345 pycharm"
result1=re.match("python", str)
print(result1.span()) # (0, 6) 字符串位置
print(result1.group()) # Python
# 匹配字符串的中间
result2=re.search("pycha", str)
print(result2.span()) # (6, 11) 字符串位置
print(result2.group()) # pycha# 匹配字符串中的所有匹配项
result3=re.findall("py", str)
print(result3) # ['py', 'py']
